package com.iwjw.ibatis.util;

import lombok.AllArgsConstructor;
import org.apache.ibatis.type.JdbcType;

/**
 * http://blog.csdn.net/sxe18652071425/article/details/46416217
 *
 * @author: huangweiwei
 * @email: ihuangweiwei@163.com
 * @created:2016/10/27
 */
@AllArgsConstructor
public enum MysqlType2JdbcType {


    BIGINT(JdbcType.BIGINT),
    TINYINT(JdbcType.TINYINT),
    SMALLINT(JdbcType.SMALLINT),
    MEDIUMINT(JdbcType.INTEGER),
    INTEGER(JdbcType.INTEGER),
    INT(JdbcType.INTEGER),
    FLOAT(JdbcType.REAL),
    DOUBLE(JdbcType.DOUBLE),
    DECIMAL(JdbcType.DECIMAL),
    NUMERIC(JdbcType.DECIMAL),
    CHAR(JdbcType.CHAR),
    VARCHAR(JdbcType.VARCHAR),
    TINYBLOB(JdbcType.BINARY),
    TINYTEXT(JdbcType.VARCHAR),
    BLOB(JdbcType.BINARY),
    TEXT(JdbcType.LONGVARCHAR),
    MEDIUMBLOB(JdbcType.LONGVARBINARY),
    MEDIUMTEXT(JdbcType.LONGVARCHAR),
    LONGBLOB(JdbcType.LONGVARBINARY),
    LONGTEXT(JdbcType.LONGVARCHAR),
    DATE(JdbcType.DATE),
    TIME(JdbcType.TIME),
    YEAR(JdbcType.DATE),
    DATETIME(JdbcType.TIMESTAMP),
    TIMESTAMP(JdbcType.TIMESTAMP);

    private JdbcType jdbcType;


    public static JdbcType get(String info) {
        for (MysqlType2JdbcType obj : values()) {
            if (obj.name().equals(info)) {
                return obj.jdbcType;
            }
        }
        return null;
    }

}
